package com.shuzijun.leetcode.editor.cn;

import java.util.HashMap;

public class SingleNumber{
    public static void main(String[] args) {
         Solution solution = new SingleNumber().new Solution();
        
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int singleNumber(int[] nums) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int count = 1;
            if (map.containsKey(nums[i])){
                count += map.get(nums[i]);
            }
            map.put(nums[i],count);
        }

        for (int i = 0; i < nums.length; i++) {
            Integer count = map.get(nums[i]);
            if (count == 1) {
                return nums[i];
            }
        }
        return -1;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}